import moment from 'moment'
export function triggerWindowResizeEvent () {
  let event = document.createEvent('HTMLEvents')
  event.initEvent('resize', true, true)
  event.eventType = 'message'
  window.dispatchEvent(event)
}
export function changeDate (data) {
  if (Object.prototype.toString.call(data) === '[object Object]') {
    for (let key in data) {
      if (/^\d{0,4}[-]\d{0,2}[-]\d{0,2}/.test(data[key])) {
        console.log(data[key])
        // if (/^\d{0,4}[-]\d{0,2}[-]\d{0,2}[ ]\d{0,2}[:]\d{0,2}[:]\d{0,2}$/.test(data[key])) {
        data[key] = moment(data[key])
      }
    }
  }
}
export function DateToString (data) {
  for (let key in data) {
    if (data[key] instanceof moment) {
      data[key] = moment(data[key]).format('YYYY-MM-DD')
    }
  }
}
